var router = require('koa-router')();
var models = require('./../../models');

/** 新建项目 */
router.post('/project', function* (next) {
    var body = this.request.body;
    yield models.Project.create({
        name: body.name,
        date: body.date
    });
    this.redirect('/home');
});

/** 项目视图,默认导航到全站仪配置里 */
router.get('/project/:id', function* (next) {
    this.redirect(`/project/${this.params.id}/stationconfig`);
});



/** 删除项目 */
router.post('/project/:id/delete', function* (next) {
    yield this.state.project.destroy();
    this.redirect('/home');
});

module.exports = router.routes();
